﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace _693607_Davies_GameUI2
{
	class Character
	{
		private PictureBox character;
		private int x;
		private int y;
		private int startingX;
		private int startingY;
		private bool movedRooms = false;

		public Character() { }
		public Character(PictureBox c) 
		{
			character = c;
			x = character.Location.X;
			y = character.Location.Y;
			startingX = character.Location.X;
			startingY = character.Location.Y;
		}

		public PictureBox CharacterImage
		{
			get { return character; }
			set { character = value; }
		}

		public int X
		{
			get { return x; }
			set { x = value; }
		}

		public int Y
		{
			get { return y; }
			set { y = value; }
		}

		public bool Move(Boolean U, Boolean D, Boolean R, Boolean L, int[] d)
		{
			if (U == true && y != 12)
			{
				y = y - 3;
			}
			if (D == true && y != 402)
			{
				y = y + 3;
			}
			if (R == true && x != 610)
			{
				x = x + 3;
			}
			if (L == true && x != 13)
			{
				x = x - 3;
			}
			character.Location = new System.Drawing.Point(x, y);

			if (d[0] == 1 && (character.Location.X <= 637 && character.Location.X >= 595) && (character.Location.Y >= 175 && character.Location.Y <= 241))
			{
				movedRooms = true;
				return movedRooms;
			}
			else if (d[1] == 1 && (character.Location.X >= 460 && character.Location.X <= 535) && (character.Location.Y >= 369 && character.Location.Y <= 435))
			{
				movedRooms = true;
				return movedRooms;
			}
			else if (d[2] == 1 && (character.Location.X >= 151 && character.Location.X <= 216) && (character.Location.Y >= 369 && character.Location.Y <= 435))
			{
				movedRooms = true;
				return movedRooms;
			}
			else if (d[3] == 1 && (character.Location.X >= 49 && character.Location.X <= 100) && (character.Location.Y >= 175 && character.Location.Y <= 241))
			{
				movedRooms = true;
				return movedRooms;
			}
			else if (d[4] == 1 && (character.Location.X >= 151 && character.Location.X <= 216) && (character.Location.Y >= 12 && character.Location.Y <= 36))
			{
				movedRooms = true;
				return movedRooms;
			}
			else if (d[5] == 1 && (character.Location.X >= 460 && character.Location.X <= 535) && (character.Location.Y >= 12 && character.Location.Y <= 36))
			{
				movedRooms = true;
				return movedRooms;
			}
			return false;
		}

		public void ResetCharacter()
		{
			character.Location = new System.Drawing.Point(startingX, startingY);
			x = startingX;
			y = startingY;
		}
	}
}
